<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* 
* @author DANG DINH HUNG
*
*/
class Escorts extends Public_Controller
{
	
	public function __construct()
	{
		parent::__construct();
		$this->load->model('escort_user_m'); 
		$this->load->model('home/escort_invoice_lines_m'); 
		if(!isLogin() || getPermission() != 'escort'){
			show_404();
			exit();
		}
		breadcumb_reset();		
		breadcumb(2,array(language_translate('breadcumb_escort'), site_url_lang("escorts")));
		if( ENVIRONMENT != 'development' ){
			force_ssl();
		}		
	}
	
	 
	public function index()
	{
	 	redirect( site_url_lang("escorts/profile") ); 
	}
	
	function profile(){
		breadcumb(3, array(language_translate('breadcumb_profile'),site_url_lang("escorts/profile")));
		
		$this->template
			->build('profile_page');
	}
	
	function myzone(){
		$this->template
			->build('myzone_page');
	}
	
	function account(){
		$task = $this->uri->segment(4,''); 
		$this->load->model('escort_account_m'); 
		switch($task){
			case 'edit':
				breadcumb(3, array(language_translate('right_nav_edit_account'),site_url_lang("escorts/account/edit")));
				$this->template->build('account/edit');
				break;
		
			case 'services':
				breadcumb(3, array(language_translate('right_nav_account_services'),site_url_lang("escorts/account/services")));
				$this->template->build('account/services');
				break;
			case 'payment_history':
				breadcumb(3, array(language_translate('right_nav_payment_history'),site_url_lang("escorts/account/payment_history")));
				$this->template->build('account/payment_history');
				break;
			case 'payment_nextmonth':
				breadcumb(3, array(language_translate('right_nav_payment_nextmonth'),site_url_lang("escorts/account/payment_nextmonth")));
				$this->template->build('account/payment_nextmonth');
				break;
            case 'messages':
                breadcumb(3, array(language_translate('right_nav_message'),site_url_lang("escorts/account/messages")));
				$this->template->build('account/support');
				break;     
			case 'support':
				breadcumb(3, array(language_translate('right_nav_support'),site_url_lang("escorts/account/support")));
				$this->template->build('account/contactpage');
				break;
			case 'log_actions':
				breadcumb(3, array(language_translate('right_nav_log_actions'),site_url_lang("escorts/account/log_actions")));
				$this->template->build('account/log_actions');
				break;	
			case 'order':
				breadcumb(3, array(language_translate('right_nav_payment_history'),site_url_lang("escorts/account/payment_history")));
				breadcumb(4, array(language_translate('services_page_payment_see_order'),'#'));
				$this->template->build('account/order');
				break;	
			case 'export_pdf':	
				//$this->template->build('account/export_pdf');
				$this->escort_account_m->export_pdf();
				break;	
            case 'gtbill_process_status':
               	breadcumb(3, array(language_translate('gtbill_process_status'),site_url_lang("escorts/account/gtbill_process_status")));
				$this->template->build('account/gtbill_process_status');
				break;     
		}
	}
	
	function transaction_submit(){
		$task = $this->uri->segment(3,''); 
		$this->load->model('escort_account_m'); 
		switch($task){
			case 'submit_services':
				$this->escort_account_m->submit_services();
				break;
			case 'submit_services_nextmonth':
				$this->escort_account_m->submit_services_nextmonth();
				break;
			case 'submit_payment':
				$this->escort_account_m->submit_payment();
				break;
            case 'calNetAmount':
				$this->escort_account_m->calNetAmount();
				break; 
            case 'payment':
				breadcumb(3, array(language_translate('right_nav_payment'),site_url("escorts/transaction_submit/payment")));
				$this->template->build('account/payment');
				break;    
            case 'creditcard_method':
           	    breadcumb(3, array(language_translate('right_nav_payment'),site_url("escorts/transaction_submit/creditcard_method")));
				$this->template->build('account/creditcard_method');
				break;    
            case 'gtbill_process':
                $this->escort_account_m->gtbill_process();
				break;     
		}
	}
	
	function submit_data(){
		$task = $this->uri->segment(3,''); 
        $this->load->model('escort_account_m'); 
		switch($task){
			case 'submit_personal_info':
				$this->escort_user_m->submit_personal_info();
				break;
			case 'submit_appareance':
				$this->escort_user_m->submit_appareance();
				break;
			case 'submit_services':	
				$this->escort_user_m->submit_services();
				break;
			case 'submit_rates':
				$this->escort_user_m->submit_rates();
				break;
			case 'submit_contact_info':
				$this->escort_user_m->submit_contact_info();
				break;
			case 'submit_edit_media':
				$this->escort_user_m->submit_edit_media();
				break;
			case 'submit_image_file':
				$this->escort_user_m->submit_image_file();
				break;
			case 'submit_send_message':
				$this->load->model('escort_zone_m'); 
				$this->escort_zone_m->submit_escort_send_message();
				break;
			case 'submit_send_message_reply_thread':
				$this->load->model('escort_zone_m'); 
				$this->escort_zone_m->submit_send_message_reply_thread();
				break;
            case 'save_change_email':
				$this->escort_account_m->save_change_email();
				break;
			case 'save_change_password':
				$this->escort_account_m->save_change_password();
				break;    
		}
		exit();
	}
	
	function async(){
		$task = $this->uri->segment(3,''); 
		switch($task){
			case 'media_manage_async':
				 $this->load->view('media_manage_async');
				 break;
			case 'loadAsyncDaysInMonth':
				$this->escort_user_m->loadAsyncDaysInMonth();
				break;
			case 'saveCalendarWorking_async':
				$this->escort_user_m->saveCalendarWorking_async();
				break;
			case 're_ordering':
				$this->escort_user_m->re_ordering();
				break;
			case 'delete_media':
				$this->escort_user_m->delete_media();
				break;
			case 'load_image_upload_form':
				$USER = getAccountUserObject();
				$ESCORT = $this->escort_entity->init('user_id',$USER->getId());
				$this->user_entity->cleanFiles($ESCORT->getId());
				$this->load->view('load_image_upload_form');
				break;
			case 'loadAsyncPersonalLanguages':	
				$this->load->view('tabs/async_partial_personal_languages_textares');
				break;
			case 'loadAsyncVideosImages':
				$this->load->view('tabs/async_partial_videos_images');
				break;
			case 'load_send_message_form':
				$this->load->view('load_send_message_form');
				break;
			case 'loadMessageOfThread':
				$this->load->view('account/async_loadMessageOfThread');
				break;
			case 'loadReplyThreadDialog':
				$this->load->view('account/async_loadReplyThreadDialog');
				break;	
			case 'loadAllThreads':
				$this->load->view('account/async_loadAllThreads');
				break;
			case 'toggleReadUnreadMessage':
				$this->load->model('escort_zone_m'); 
				$this->escort_zone_m->toggleReadUnreadMessage();
				break;
			case 'deleteMessage':
				$this->load->model('escort_zone_m'); 
				$this->escort_zone_m->deleteMessage();
				break;
			case 'getDialog_openMostPopularImage':
				$this->load->view('tabs/async_getDialog_openMostPopularImage');
				break;	
			case 'loadActionsLog':
				$this->load->view('account/async_loadActionsLog');
				break;
			case 'save_promotion_code':
				$this->load->model('escort_account_m'); 
				$this->escort_account_m->save_promotion_code();
				break;
			case 'image_face_censor':
				$this->escort_user_m->image_face_censor();
				break;	
			case 'load_listing_place_element':
				$this->load->view('account/async_loadListingPlaceElement');
				break;	
		}
		
	}
	
	
	
	
	//end class
}